import request from "@/utils/request";

//品牌列表中每一个品牌的具体类型
export interface trademarkItemType {
  id?: number;
  tmName: string; //品牌名称
  logoUrl: string; //品牌logo
}

//品牌列表的数组类型
export type trademarkListType = trademarkItemType[];

//品牌分页列表的返回值类型
export interface trademarkListReturnType {
  records: trademarkListType; //品牌列表数据
  total: number; //总条数
  size: number; //每页条数
  current: number; //当前页
  searchCount: boolean;
  pages: number; //总页数
}

//1. 请求品牌分页列表
export const reqTrademarkList = (page: number, limit: number) => {
  return request.get<null, trademarkListReturnType>(
    `/admin/product/baseTrademark/${page}/${limit}`
  );
};

//2. 新增品牌的请求
export const reqAddTrademark = (tmInfo: trademarkItemType) => {
  return request.post<null, null>(`/admin/product/baseTrademark/save`, tmInfo);
};

//3. 修改品牌请求
export const reqUpdateTrademark = (tmInfo: trademarkItemType) => {
  return request.put<null, null>(`/admin/product/baseTrademark/update`, tmInfo);
};

//4. 删除品牌的请求
export const reqDeleteTrademark = (id: number) => {
  return request.delete<null, null>(
    `/admin/product/baseTrademark/remove/${id}`
  );
};

//5. 获取所有品牌
export const reqAllTrademark = () => {
  return request.get<null, trademarkListType>(
    `/admin/product/baseTrademark/getTrademarkList`
  );
};
